/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.Random;
import java.util.Scanner;

/**
 * <p>Project: jse2303 - GuessNumGame
 * <p>Powered by webrx On 2023-07-11 17:43:15
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class GuessNumGame {
    public static void main(String[] args) {
        //声明数组 7级
        int[] level = {50, 100, 200, 500, 1000, 2000, 5000};

        //1-100
        Random rand = new Random();
        Scanner sc = new Scanner(System.in);
        int le = level[rand.nextInt(level.length)];
        int num = rand.nextInt(1, le + 1);
        int i = 0;
        while (true) {
            ++i;
            System.out.print("请输入[1-" + le + "]:");
            int t = sc.nextInt();
            if (t > num) {
                System.out.printf("%d、\033[31m太大了\033[0m%n", i);
            } else if (t < num) {
                System.out.printf("%d、\033[31m太小了\033[0m%n", i);
            } else {
                System.out.printf("%d、\033[32m恭喜猜对了，游戏得%d分.\033[0m%n", i, (110 - i * 10));
                break;
            }
        }
        System.out.println("\033[33m游戏结束\033[0m");
    }
}
